import Button from "components/Base/Button";
import Icon from "components/Base/Icon";
import DataTable from "components/Base/DataTable";

export default (self) => [
  {
    title: 'id',
    name: 'id',
    formItem: {
      type: 'hidden',
    }
  },
  {
    title: '设备ID',
    name: 'deviceId',
    tableItem: {},
    formItem: {
      rules: [
        {
          required: true,
          message: '请输入设备ID'
        }
      ]
    },
  },
  {
    title: '所属医院',
    name: 'hospitalName',
    tableItem: {},
    formItem: {
      rules: [
        {
          required: true,
          message: '请选择医院'
        }
      ],

      showSearch: true,
      type: 'select',
      loading: self.getHospital().loadingAll,  // 加载状态
      onDropdownVisibleChange: (visible) => {
        if (visible) {
          self.dispatch({
            type: `hospital/getAll`,
          })
        }
      },

      filterOption: (input, option) => {
        return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
      },
      dict: self.getHospital().dict,
    },
  },

  {
    title: '状态',
    name: 'workStatus',
    dict: [
      {code: 'ONLINE', codeName: '在线'},
      {code: 'OFFLINE', codeName: '离线'},
    ],
    tableItem: {
      filters: [
        {
          value: 'ONLINE',
          text: '在线',
        },
        {
          value: 'OFFLINE',
          text: '离线',
        },
      ]
    },
    formItem: {
      type: 'hidden'
    }
  },
  {
    title: '运行模式',
    name: 'runMode',
    tableItem: {
      filters: [
        {
          value: 'STANDALONE',
          text: '单机模式',
        },
        {
          value: 'LIS',
          text: 'lis模式',
        },
      ]
    },
    dict: [
      {code: 'STANDALONE', codeName: '单机模式'},
      {code: 'LIS', codeName: 'lis模式'},
    ],
    formItem: {
      type: 'select',
      rules: [
        {
          required: true,
          message: '请选择设备运行模式'
        }
      ]
    }
  },
  {
    title: '最后一次数据时间',
    name: 'lastTime',
    tableItem: {},
  },
  {
    title: '软件版本号',
    name: 'softVersion',
    tableItem: {},
  },
  {
    title: '操作',
    tableItem: {
      width: 180,
      render: (text, record) => {

        return (
          <DataTable.Oper>
            <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
              <Icon type="edit"/>
            </Button>
            <Button tooltip="删除" onClick={e => self.onDelete(record)}>
              <Icon type="trash"/>
            </Button>
          </DataTable.Oper>
        )
      }
    }
  }
]
